<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<%--<div id="page-calendar">--%>
<div class="row">

    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-body">
                <input type="hidden" name="prjId" id="prjId" value="${prjId}" />
                <!-- Calendar placeholder-->
                <!-- ============================================ -->
                <div id='calendar'></div>
                <!-- ============================================ -->
            </div>
        </div>
    </div>

</div>
<%--</div>--%>

<script>

    function initCalendar(){
        calendarTask = $('#page-calendar #calendar').fullCalendar({
            header: {
                left: 'prev,next',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
            monthNamesShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
            dayNames: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
            dayNamesShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
            today: ["今天"],
            firstDay: 1,
            buttonText: {
                today: '今天',
                month: '月',
                week: '周',
                day: '日',
                prev: '上一周期',
                next: '下一周期'
            },
            allDayText: '全天',
            eventLimit: true, // allow "more" link when too many events
            allDayDefault: true,
            editable: false,
            droppable: false, // this allows things to be dropped onto the calendar
            currentTimezone: 'Asia/Shanghai',
            timeFormat: 'H:mm',
            events: function(start, end, timezone, callback) {
                var prjId = $("#prjId").val();
                $.ajax({
                    url: '<%=path%>/com/task/listCalendar',
                    cache: false,
                    dataType: 'json',
                    data: {
                        start: start.format(),
                        end: end.format(),
                        catalog: 1,
                        prjId: prjId
                    },
                    success: function(data) {
                        var rows = $(data.dataRows);
                        if(rows.length>0){
                            var events = [];
                            rows.each(function(i,item) {
                                events.push({
                                    className: item.className,
                                    title: item.name,
                                    start: item.start,
                                    end: item.end,
                                    id: item.id
                                });
                            });
                            callback(events);
                        }
                    },
                    error:function() {
                        __toastr_error('请求数据出错');
                    }
                });
            },
            eventClick : function( event ){
                //do something here...
                console.log('eventClick中选中Event的id属性值为：', event.id);
//                fn_meeting_read(event.id);
            },
            eventMouseover : function( event ) {
                // do something here...
                // console.log('eventMouseover被执行，选中Event的title属性值为：', event.title);
            }
        });
    }

    $(function(){
        initCalendar();
    });

</script>